/**
 * Copyright (C) 2010 DustedPixels.com
 */
package com.dustedpixels.cirt.model.machine.spectrum.ula;

import com.dustedpixels.cirt.model.core.Circuit;
import com.dustedpixels.cirt.model.core.In;
import com.dustedpixels.cirt.model.core.Out;
import com.dustedpixels.cirt.model.core.Pins;
import com.dustedpixels.cirt.model.core.Script;

/**
 * AttrDecoder
 *
 * @author Michal Pociecha-Los (micapolos@gmail.com)
 */
@Circuit
public final class AttrDecoder {
  @In @Pins(8) public int attr;
  
  @Out public boolean flash;
  @Out public boolean bright;
  @Out @Pins(3) public int paperColor;
  @Out @Pins(3) public int inkColor;
  
  @Script
  public void decode() {
    flash = (attr & 0x80) != 0;
    bright = (attr & 0x40) != 0;
    paperColor = (attr >>> 3) & 0x07; 
    inkColor = attr & 0x07; 
  }
}
